package com.demo;

import com.alibaba.fastjson.JSON;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.ai.chat.model.ChatResponse;
import org.springframework.ai.chat.prompt.Prompt;
import org.springframework.ai.ollama.OllamaChatModel;
import org.springframework.ai.ollama.api.OllamaOptions;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

@Slf4j
@RunWith(SpringRunner.class)
@SpringBootTest
public class ApiTest {
    @Resource
    private OllamaChatModel ollamaChatModel;

    //测试ollama部署模型是否可用
    @Test
    public void test_call() {
        ChatResponse response = ollamaChatModel.call(new Prompt(
                        "苹果的英文是什么",
                        OllamaOptions.builder().model("deepseek-r1:1.5b").build()
                )
        );
        log.info("结果：{}", JSON.toJSONString(response));
    }
}
